#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project ：python常用模块库 
@File ：time_policy.py
@IDE  ：PyCharm 
@Author ：李涵彬
@Date ：2025/2/21 上午8:58 
"""

from datetime import datetime, timedelta
from pathlib import Path
from typing import List, Dict


class TimePolicy:
	def __init__(self, retention_days: int):
		self.retention = timedelta(days=retention_days)

	def apply(self, files: List[Dict]) -> List[Path]:
		"""时间保留策略"""
		cutoff = datetime.now() - self.retention
		return [
			f["path"] for f in files
			if datetime.fromtimestamp(f["mtime"]) < cutoff
		]
